<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
    
<head>
        <title>Maruti Admin</title><meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="assets/css/bootstrap-responsive.min.css" />
        <link rel="stylesheet" href="assets/css/maruti-login.css" />
    </head>
    <body>
        <div id="logo">
            <img src="assets/img/login-logo.png" alt="" />
        </div>
        <div id="loginbox">            
            <form id="loginform" class="form-vertical">
				 <div class="control-group normal_text"><h2 class="text-error">锁屏收益后台</h2></div>
                <div class="control-group">
                    <div class="controls">
                        <div class="main_input_box">
                        	<br/>
                            <span class="add-on"><i class="icon-user"></i></span><input id = "usrename" name="uname" type="text"  onblur="checkUname(this.value)" placeholder="Username" />
                            <br/>
                            <span id="errorMusername"></span>
                        </div>
                    </div>
                </div>
                <div class="control-group">
                    <div class="controls">
                        <div class="main_input_box">
                        	<br/>
                            <span class="add-on"><i class="icon-lock"></i></span><input id ="passwd" name="password" type="password" onblur="checkPassWD(this.value)" placeholder="Password" />
                            <br/>
                            <span id="errorPwd"></span>
                        </div>
                    </div>
                </div>
                <div class="form-actions">
                    <span class="pull-right" style="margin-right: 45px;"><input  id="btnLogin" onclick="login();"  class="btn btn-success" value="Login" /></span>
                </div>
            </form>
        </div>
        <script src="assets/js/jquery.min.js"></script>  
        <script type="text/javascript">
        	function checkUname(value){
        		if(value.length<=0){
        			$("#errorMusername").css("color", "red").text("*用户名不为空");
        			return false;
        		}
        		return true;
        	}
        
	        function checkPassWD(value){
	        	if(value.length<=0){
        			$("#errorPwd").css("color", "red").text("*密码不为空");
        			return false;
        		}
        		return true;
	        }
        
	        function login(){
	          var username=$("#usrename").val();
	          var pwd=$("#passwd").val();
	          var mydata = '{"uname":"' + username + '","passwd":"' + pwd + '"}'; 
	          
	          $.ajax({
	          		type:"post",
	          		contentType : 'application/json',
	          		url:"${pageContext.request.contextPath}/person/login.do",
	          		data:mydata,
	          		processData : false,
	          		datatype:"json",
	          		success: function(data){
												if(data.status==0){
													alert(data.message);
													$("#usrename").attr("value","");
													$("#passwd").attr("value","");
												}else if(data.status==1){
													document.location.href="${pageContext.request.contextPath}/main.do";
												}                      
                                             } 
	          });
	        }
        </script>
    </body>
</html>
